//https://leetcode.cn/problems/wtcaE1/description/
class Solution {
public:
    int lengthOfLongestSubstring(string s) {
        int left = 0, right = 0;
        int hash[128] = { 0 };
        int len = 0;
        while (right < s.size())
        {
            hash[s[right]]++;
            while (hash[s[right]] > 1)
            {
                hash[s[left++]]--;
            }
            len = max(right - left + 1, len);
            right++;
        }

        return len;
    }
};